#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;




//char string_to_ERegisterType(const string& in_str)
//{
//    size_t size = in_str.size();
//    char hash_value = in_str.at(5 < size ? 5 : 5 % size) ^ in_str.at(6 < size ? 6 : 6 % size);
//
//    return hash_value;
//
//}

char string_to_ERegisterType(const string& in_str)
{
    size_t size = in_str.size();
    //char hash_value = in_str.at( 4< size ? 4 : 4 % size) ^ in_str.at(6 < size ? 6 : 6 % size)^in_str.at(9 < size ? 9 : 9 % size);
    char hash_value = in_str.at( 4< size ? 4 : 4 % size) ^ in_str.at(5 < size ? 5 : 5 % size)
                      ^in_str.at(6 < size ? 6 : 6 % size)^in_str.at(7 < size ? 7 : 7 % size)
                      ^in_str.at(1 < size ? 1  : 1 % size)^in_str.at(2 < size ? 2  : 2 % size);

    return hash_value;

}



int main()
{
    cout << "Hello World\n"<<endl;

    std::vector<std::uint32_t> hash;
    std::vector<std::string> Types = {
    "BCU", 
    "BRU", 
    "CVT", 
    "CVT64", 
    "DALU", 
    "FALU",  
    "HALU", 
    "IALU", 
    "LSU", 
    "MISC", 
    "IB", 
    "MMA", 
    "SYNCOp", 
    };

    bool conflict = false;
    int  value=0;
    for(auto &type : Types)
    {
       uint32_t num = string_to_ERegisterType(type);
       if(std::find(hash.begin(), hash.end(), num) != hash.end()){
         conflict =true;
         value = num;
       }
       hash.push_back(num);
       
          
       std::cout<<type<<" "<<static_cast<uint32_t>(string_to_ERegisterType(type))<<std::endl;

    }

    if(conflict){

       printf("conflict value is  %d\n", value);
    }
    else
       printf("no hash conflict \n");

    return 0;
}